////由于非实际环境无sdk，先全部注释防止报错
//#include <stdio.h>
//#include <dlfcn.h>

//int main() {
//    void *libusb_handle;
//    void *libseabreeze_handle;

//    // 加载libusb.so，并设置为具有全局符号可见性
//    libusb_handle = dlopen("/usr/lib/libusb.so", RTLD_LAZY | RTLD_GLOBAL);
//    if (!libusb_handle) {
//        fprintf(stderr, "%s\n", dlerror());
//        return 1;
//    }

//    // 加载libseabreeze.so
//    libseabreeze_handle = dlopen("/usr/lib/libseabreeze.so", RTLD_LAZY);
//    if (!libseabreeze_handle) {
//        fprintf(stderr, "%s\n", dlerror());
//        return 1;
//    }

//    double WaveLenght[2048];
//    int err = -1;
//--------------------------------------------------------------------------------------------------------------------------
//    // 获取函数指针（已跑通，未进行类型转换）
//    // 打开usb光谱仪,如果只有一个光谱仪默认是0
//    int (*seabreeze_open_spectrometer)(int, int *) = dlsym(libseabreeze_handle, "seabreeze_open_spectrometer");
//    // 关闭usb光谱仪
//    int (*seabreeze_close_spectrometer)(int, int *) = dlsym(libseabreeze_handle, "seabreeze_close_spectrometer");
//    // 获取光谱仪型号
//    int (*seabreeze_get_modle)(int, int*, char *, int) = dlsym(libseabreeze_handle, "seabreeze_get_modle");
//    // 设置光谱仪积分时间，注意是微秒
//    void (*seabreeze_set_integration_time_microsec)(int , int *, unsigned long) = dlsym(libseabreeze_handle, "seabreeze_set_integration_time_microsec");
//    // 获取光谱
//    int (*seabreeze_get_formatted_spectrum)(int , int *, double * , int) = dlsym(libseabreeze_handle, "seabreeze_get_formatted_spectrum");
//    // 获取光谱仪，波长范围
//    int (*seabreeze_get_wavelengths)(int, int *, double *, int) = dlsym(libseabreeze_handle, "seabreeze_get_wavelengths");
//    // 获取光谱仪序列号
//    int (*seabreeze_get_serial_number)(int , int *, char *, int ) = dlsym(libseabreeze_handle, "seabreeze_get_serial_number");
//    //
//    int (*seabreeze_open_all_spectrometers)(int *) = dlsym(libseabreeze_handle, "seabreeze_open_all_spectrometers");
//    //设置激光开关，0是关闭，1是打开
//    int (*seabreeze_set_laser_switch)(int ,int *,int) = dlsym(libseabreeze_handle, "seabreeze_set_laser_switch");
//    //设置激光功率
//    int (*seabreeze_set_laser_power)(int ,int *,int) = dlsym(libseabreeze_handle, "seabreeze_set_laser_power");
//---------------------------------------------------------------------------------------------------------------------------
//// 获取函数指针，进行了类型转换的
//// 打开usb光谱仪,如果只有一个光谱仪默认是0
//int (*seabreeze_open_spectrometer)(int, int*) = reinterpret_cast<int (*)(int, int*)>(dlsym(libseabreeze_handle, "seabreeze_open_spectrometer"));
//// 关闭usb光谱仪
//int (*seabreeze_close_spectrometer)(int, int*) = reinterpret_cast<int (*)(int, int*)>(dlsym(libseabreeze_handle, "seabreeze_close_spectrometer"));
//// 获取光谱仪型号
//int (*seabreeze_get_modle)(int, int*, char*, int) = reinterpret_cast<int (*)(int, int*, char*, int)>(dlsym(libseabreeze_handle, "seabreeze_get_modle"));
//// 设置光谱仪积分时间，注意是微秒
//void (*seabreeze_set_integration_time_microsec)(int, int*, unsigned long) = reinterpret_cast<void (*)(int, int*, unsigned long)>(dlsym(libseabreeze_handle, "seabreeze_set_integration_time_microsec"));
//// 获取光谱
//int (*seabreeze_get_formatted_spectrum)(int, int*, double*, int) = reinterpret_cast<int (*)(int, int*, double*, int)>(dlsym(libseabreeze_handle, "seabreeze_get_formatted_spectrum"));
//// 获取光谱仪，波长范围
//int (*seabreeze_get_wavelengths)(int, int*, double*, int) = reinterpret_cast<int (*)(int, int*, double*, int)>(dlsym(libseabreeze_handle, "seabreeze_get_wavelengths"));
//// 获取光谱仪序列号
//int (*seabreeze_get_serial_number)(int, int*, char*, int) = reinterpret_cast<int (*)(int, int*, char*, int)>(dlsym(libseabreeze_handle, "seabreeze_get_serial_number"));
////
//int (*seabreeze_open_all_spectrometers)(int*) = reinterpret_cast<int (*)(int*)>(dlsym(libseabreeze_handle, "seabreeze_open_all_spectrometers"));
////设置激光开关，0是关闭，1是打开
//int (*seabreeze_set_laser_switch)(int, int*, int) = reinterpret_cast<int (*)(int, int*, int)>(dlsym(libseabreeze_handle, "seabreeze_set_laser_switch"));
////设置激光功率
//int (*seabreeze_set_laser_power)(int, int*, int) = reinterpret_cast<int (*)(int, int*, int)>(dlsym(libseabreeze_handle, "seabreeze_set_laser_power"));
//--------------------------------------------------------------------------------------------------------------------------
//    // 调用函数
//    seabreeze_open_spectrometer(0,&err); //打开

//    seabreeze_set_integration_time_microsec(0,&err,1000*1000);//设置积分时间

//    double signal[2048];
//    seabreeze_get_formatted_spectrum(0,&err,signal,2048);//

//    seabreeze_set_laser_switch(0 ,&err , 1);//打开激光

//    seabreeze_set_laser_power(0 , &err ,350);//设置激光功率


//    double LightSignal[2048];
//    seabreeze_get_formatted_spectrum(0,&err,LightSignal,2048);

//    double result[2048];
//    for(int i=0; i<2048;i++){
//        result[i] = LightSignal[i] - signal[i];
//        printf("%f\n",result[i]);
//    }

//    seabreeze_set_laser_switch(0 ,&err , 0);//close激光

//    seabreeze_close_spectrometer(0 ,&err); // 关闭
//    printf("close\n");
//    // 继续调用其他函数

//    dlclose(libseabreeze_handle);
//    return 0;
//}
